package com.shushan.exam.bean;

import android.text.TextUtils;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @ClassName: ExerciseOptionBean
 * @Desciption:  题目选项
 * @author: yichaohua
 * @date: 2018-04-18
 */
public class ExerciseOptionBean extends NetBaseBean {

    public int id;//选项ID
    public int exercises_id;//习题ID
    public String option_content;//选项内容
    public String option_imgs;//选项图片
    public String image_size;//图片大小
    public int option_result;//0：选项错误1正确
    public String content_type;//内容类型 TEXT 纯文本，TEXT_IMG 图文

    private int answerIndex = -1;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        id = jsonObject.optInt("id",0);
        exercises_id = jsonObject.optInt("exercises_id",0);
        option_content = jsonObject.optString("option_content","");
        if(!TextUtils.isEmpty(option_content)){
            JSONArray jsonArray = new JSONArray(option_content);
            option_content = "";
            for (int i = 0;i < jsonArray.length();i++){
                option_content += jsonArray.optString(i);
            }
        }

        option_imgs = jsonObject.optString("option_imgs","");
        image_size = jsonObject.optString("image_size","");
        option_result = jsonObject.optInt("option_result",0);
        content_type = jsonObject.optString("content_type","");
    }

    public int getAnswerIndex() {
        return answerIndex;
    }

    public void setAnswerIndex(int answerIndex) {
        this.answerIndex = answerIndex;
    }
}
